import Vue from "vue";
import axios from "axios";

const $axios =axios.create({
    baseURL: 'http://localhost:12587/restaurant-administration/',
    timeout: 4000,
    headers: {'Content-Type': 'application/json'},
    withCredentials:false
})
//在发送axios请求时做点什么
$axios.interceptors.request.use(function (config) {
    if (sessionStorage.getItem("clerk")!=null){
        let clerk = JSON.parse(sessionStorage.getItem("clerk")).roleId;
        config.headers.common['clerk-id'] = clerk;
    }
    config.headers.common['root'] = "rear";

    return config
},function (error) {
    return Promise.reject(error);
})

Vue.prototype.$axios = $axios

export default $axios